<?php
//kategori
function kategoriDropdown($selected=FALSE)
{
	$ci=& get_instance();
    $ci->load->Model('Kategori_model');
    $res = $ci->Kategori_model->getKategori('list',FALSE);

    $output = "<select id='id_kategori' name='id_kategori' class='title'>";
		$output .= "<option value=''> - Pilih - </option>";
		foreach($res as $row):
		    if($selected):
		    	if($row["id_kategori"]==$selected):
					$output .= "<option value='".$row["id_kategori"]."' selected='selected'>".$row['nama_kategori']."</option>";
				else:
					$output .= "<option value='".$row["id_kategori"]."'>".$row['nama_kategori']."</option>";
				endif;
		    else:
		    	$output .= "<option value='".$row["id_kategori"]."'>".$row['nama_kategori']."</option>";
		   endif;
		endforeach;
	$output .= "</select>";
    return $output;
}

//penerbit
function penerbitDropdown($selected=FALSE)
{
	$ci=& get_instance();
    $ci->load->Model('Penerbit_model');
    $res = $ci->Penerbit_model->getPenerbit('list',FALSE);

    $output = "<select id='id_penerbit' name='id_penerbit' class='title'>";
		$output .= "<option value=''> - Pilih - </option>";
		foreach($res as $row):
		    if($selected):
		    	if($row["id_penerbit"]==$selected):
					$output .= "<option value='".$row["id_penerbit"]."' selected='selected'>".$row['nama_penerbit']."</option>";
				else:
					$output .= "<option value='".$row["id_penerbit"]."'>".$row['nama_penerbit']."</option>";
				endif;
		    else:
		    	$output .= "<option value='".$row["id_penerbit"]."'>".$row['nama_penerbit']."</option>";
		   endif;
		endforeach;
	$output .= "</select>";
    return $output;
}

//kelamin

function jnsKelDropdown($selected=FALSE) {

$options = array(
                  'L'  => 'Laki-Laki',
                  'P'    => 'Perempuan',
                  
                );	
return form_dropdown('kelamin',$options,$selected);
}

//judul buku
function bukuDropdown($selected=FALSE)
{
   	$ci=& get_instance();
	$ci->db->select('id_buku,judul');
	$res = $ci->db->get('tb_buku')->result_array();
	

    $output = "<select id='id_buku' name='id_buku' class='title'>";
		$output .= "<option value=''> - Pilih - </option>";
		foreach($res as $row):
		    if($selected):
		    	if($row["id_buku"]==$selected):
					$output .= "<option value='".$row["id_buku"]."' selected='selected'>".$row['judul']."</option>";
				else:
					$output .= "<option value='".$row["id_buku"]."'>".$row['judul']."</option>";
				endif;
		    else:
		    	$output .= "<option value='".$row["id_buku"]."'>".$row['judul']."</option>";
		   endif;
		endforeach;
	$output .= "</select>";
    return $output;
}
